package com.jala.user.service.impl;

import com.jala.cm.PageResult;
import com.jala.user.mapper.UserMapper;
import com.jala.user.model.User;
import com.jala.user.req.PageUserReq;
import com.jala.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/3/13.
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public PageResult<User> pageUserList(PageUserReq req) {
        PageResult<User> result = new PageResult<User>();
        int offset = req.getLimitOffset();
        int pageSize = req.getPageSize();
        List<User> users = userMapper.listUser(offset, pageSize, req.getLoginId(), req.getUserName(), req.getState());
        int counts = userMapper.countUser(req.getLoginId(), req.getUserName(), req.getState());
        result.setResults(users);
        result.setTotalResults(counts);
        return  result;
    }

}
